﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Common;
using System.Text;

public partial class Script_ScriptMemory : BasePage
{
    protected int id = 0;
    protected string channel = "";
    protected int num = 0;
    protected bool IsScroll = false;
    protected int h = 0;
    protected string ChangeObjValue = "Memory";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["id"] != null)
        {
            id = StringHelper.isNumber_int(Request["id"].ToString());
        }
        if (Request["Objid"] != null)
        {
            ChangeObjValue = Request["Objid"].ToString();
        }

        if (Request["channel"] != null)
        {
            channel = Request["channel"].ToString();
        }
        if (Request["num"] != null)
        {
            num = StringHelper.isNumber_int(Request["num"].ToString());
        }
        if (Request["IsScroll"] != null)
        {
            try
            {
                IsScroll = Convert.ToBoolean(Request["IsScroll"]);
            }
            catch
            {
                IsScroll = false;
            }
        }
        if (Request["h"] != null)
        {
            h = StringHelper.isNumber_int(Request["h"].ToString());
        }




        if (id <= 0 || channel == "")
        {
            Response.Write("$(\"#" + ChangeObjValue + "\").html('参数出错!');");
        }
        else
        {

            #region 滚动
            Response.Write("function Marquee() { ");
            Response.Write("if (demo2.offsetHeight - demo.scrollTop <= 0){");
            Response.Write("demo.scrollTop -= demo1.offsetHeight;}");
            Response.Write("else {");
            Response.Write("  demo.scrollTop++;");
            Response.Write(" }");
            Response.Write(" }");

            #endregion

            Response.Write("var IsSacrifice=0;var speed = 50; ");//最新纪念是否加载完成
            Response.Write("var ReplaceOldStr=$(\"#" + ChangeObjValue + "\").html();");
            Response.Write("$.ajax({");
            Response.Write("url:\"" + configInfo.InstallDir + "AjaxXml/SacrificeAjax.Aspx?num=" + num + "&id=" + id + "&channel=" + channel + "&rnd=\"+Math.random(),");
            Response.Write("type: 'POST',");
            Response.Write("data: 'Cnt='+escape(ReplaceOldStr),");
            Response.Write("dataType: \"html\",");
            Response.Write("beforeSend: function() {");
            Response.Write("$(\"#" + ChangeObjValue + "\").html(\"<img src='" + configInfo.InstallDir + "images/007.gif' align='absmiddle' >加载中...\");");
            Response.Write("},");

            Response.Write("error:function(data) {");
            Response.Write("$(\"#" + ChangeObjValue + "\").html('错误!');");
            Response.Write("},");

            Response.Write("success:function(data)  {");
            // Response.Write("$(\"#" + ChangeObjValue + "\").html(data);");
            if (!IsScroll)
            {
                Response.Write("$(\"#" + ChangeObjValue + "\").html(data);");
            }
            else
            {
                Response.Write("$(\"#" + ChangeObjValue + "\").html(\"<div id=demo style='overflow:hidden;height:" + h + "px;width:100%' align='conter'><table width='100%'  align=top><tr><td id=demo1 valign=top>\"+data+\"</td></tr><tr><td id='demo2' valign='top'></td></tr></table></div>\");");
            }

            //Response.Write("$(\"#" + ChangeObjValue + "\").each(function(){$(this).html(data)});");
            Response.Write("},");
            Response.Write("complete:function(data,textStatus) {");

            if (IsScroll)
            {
                Response.Write("if($('#demo1').height()>" + h + "){");
                Response.Write("if(textStatus==\"success\"){");
                Response.Write("demo2.innerHTML = demo1.innerHTML;");
                Response.Write("var MyMar = setInterval(Marquee, speed);");
                Response.Write("demo.onmouseover = function() { clearInterval(MyMar);};");
                Response.Write("demo.onmouseout =function(){");
                Response.Write("MyMar = setInterval(Marquee, speed);}");
                Response.Write("};");
                Response.Write("};");

            }



            Response.Write("}");


            Response.Write("})");




            #region MyRegion
            //strBuilder.AppendLine(" marqueesHeight=500;");
            //strBuilder.AppendLine("  stopscroll=false;    ");
            //strBuilder.AppendLine("  with(marquees){   ");
            //strBuilder.AppendLine("      style.width=0;   ");
            //strBuilder.AppendLine("      style.height=marqueesHeight;   ");
            //strBuilder.AppendLine("     style.overflowX=\"visible\";  ");
            //strBuilder.AppendLine("     style.overflowY=\"hidden\";   ");
            //strBuilder.AppendLine("     noWrap=true;");
            //strBuilder.AppendLine("     onmouseover=new   Function(\"stopscroll=true\"); ");
            //strBuilder.AppendLine("     onmouseout=new   Function(\"stopscroll=false\");  ");
            //strBuilder.AppendLine(" }   ");
            //strBuilder.AppendLine(" document.write('<div   id=\"templayer\"   style=\"position:absolute;z-index:1;visibility:hidden\"></div>');   ");

            //strBuilder.AppendLine(" preTop=0;   currentTop=0;   ");

            //strBuilder.AppendLine(" function   init(){   ");
            //strBuilder.AppendLine("     templayer.innerHTML=\"\";   ");
            //strBuilder.AppendLine("     while(templayer.offsetHeight<marqueesHeight){  ");
            //strBuilder.AppendLine("        templayer.innerHTML+=marquees.innerHTML;   ");
            //strBuilder.AppendLine("    }   ");
            //strBuilder.AppendLine("    marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;   ");
            //strBuilder.AppendLine("   setInterval(\"scrollUp()\",80);   ");
            //strBuilder.AppendLine("}  ");
            //strBuilder.AppendLine("document.body.onload=init; ");

            //strBuilder.AppendLine(" function   scrollUp(){ ");
            //strBuilder.AppendLine("    if(stopscroll==true)   return;");
            //strBuilder.AppendLine("    preTop=marquees.scrollTop;");
            //strBuilder.AppendLine("   marquees.scrollTop+=1;  ");
            //strBuilder.AppendLine("   if(preTop==marquees.scrollTop){   ");
            //strBuilder.AppendLine("     marquees.scrollTop=templayer.offsetHeight-marqueesHeight; ");
            //strBuilder.AppendLine("     marquees.scrollTop+=1;   );");
            //strBuilder.AppendLine(" }  ");
            //strBuilder.AppendLine("}"); 
            #endregion


        }




    }
}
